#!/usr/bin/env python
# -*- coding: utf-8 -*-

from code import Code

""" 構文木背景消去命令クラス """
class ClearBg:
	def __init__(self):
		pass
	def initialize(self, paramList):
		self.paramList = paramList
		self.count = len(self.paramList)
		if self.count > 1:
			raise "Error: DrawBg() invalid parameter count. [%d]"%self.count
	def run(self, writer):
		# 命令書き込み
		# [opecode, effectId]
		# [1      , 1       ]
		# = 2byte
		writer.writeByte(Code.CODE_CLEAR_BG)
		
		if self.count == 0:
			# デフォルト引数
			effectId = Code.EF_NORMAL
		else:
			effectId = self.paramList[1].getValue()
		writer.writeByte(effectId)
		writer.writeLog("背景消去, %r"%(effectId))
	def getInstance():
		""" インスタンスの生成 """
		return ClearBg()
	getInstance = staticmethod(getInstance)